<?php 

$a_mmUe =array();
$trFotos="";
$trPendientesFotos= "<tr><td colspan=4 ></td></tr><tr><td colspan='4' ><b>Fotos pendientes por registrar:</b><br></td></tr><tr><td colspan=4 ></td></tr>".listaFilesMm($UPLOAD_DIR, $UPLOAD_URL, $usuario.'/f/' );
$trPlanos="";
$trPendientesPlanos= "<tr><td colspan=4 ></td></tr><tr><td colspan='4' ><b>Planos pendientes por registrar:</b><br></td></tr><tr><td colspan=4 ></td></tr>".listaFilesMm($UPLOAD_DIR, $UPLOAD_URL, $usuario.'/p/' );
$trVideos="";
$trPendientesVideos= "<tr><td colspan=4 ></td></tr><tr><td colspan='4' ><b>Videos pendientes por registrar:</b><br></td></tr><tr><td colspan=4 ></td></tr>".listaFilesMm($UPLOAD_DIR, $UPLOAD_URL, $usuario.'/v/' );
$trInformes="";
$trPendientesInformes= "<tr><td colspan=4 ></td></tr><tr><td colspan='4' ><b>Informes pendientes por registrar:</b><br></td></tr><tr><td colspan=4 ></td></tr>".listaFilesMm($UPLOAD_DIR, $UPLOAD_URL, $usuario.'/i/' );

if($codUe){
	
	$a_fotos = uEstratigraficaBN::getListaMm($codUe,"f");
	$tablafotos = "";
	$url_mm = '../../multimedia/'.$codUe.'/';
	$trFotos.= listaFilesMultimedias($a_fotos , 'checkboxF');
		
	$a_planos = uEstratigraficaBN::getListaMm($codUe,"p");
	$trPlanos.= listaFilesMultimedias($a_planos , 'checkboxP');
		
	$a_video = uEstratigraficaBN::getListaMm($codUe,"v");
	$trVideos.= listaFilesMultimedias($a_video , 'checkboxV');
	
	$a_informe = uEstratigraficaBN::getListaMm($codUe,"i");
	$trInformes.= listaFilesMultimedias($a_informe , 'checkboxI');
			
}

function listaFilesMultimedias($a_obj , $name){
    
	
	
	
	$tr = "<tr>";
	$i=1;
	foreach ($a_obj as $obj){
				
		$ext = strtoupper(end(explode(".", $obj->getTitulo())));
		$ali = array("GIF"=>'gif',"JPG"=>'JPG',"JPEG"=>'JPEG',"PNG"=>'PNG');
		if(isset($ali[$ext])){
			$tr.= "<td width='80'><div align='center'><img alt='' src='".$obj->getDescripcion()."' width='80' height='69' /><br />
	                        <FONT FACE='arial' SIZE=1 > ".$obj->getTitulo()." </FONT>
	                        <input type='checkbox' id='".$name."_".$i."' name='".$name."_".$i."' value='".$obj->getCodmm()."' />
	                      </div></td>" ;
		}else{
			$tr.="<td width='80' valign='bottom' ><a download='".$obj->getDescripcion()."' rel='' title='".$obj->getTitulo()."' href='".$obj->getDescripcion()."'  ><FONT FACE='arial' SIZE=1 >".$obj->getTitulo()."</FONT></a>
					<input type='checkbox' id='".$name."_".$i."' name='".$name."_".$i."' value='".$obj->getCodmm()."' />
					</td>";
		}
					
		
		
		if(fmod($i, 4) == 0){
			$tr.="</tr><tr>";
		}
		$i++;
		
	}
	$tr .= "</tr>";
	return $tr;
}


?>
<div id="checkboxes" >
			 <fieldset  >
                <legend>FOTOS</legend>
                <table width="480" border="1" align="center">
                   <tr>
                    <td colspan=4 ><div align="right">
                    	<a href="#" id="linkAddFoto" onclick="eliminarFile('f')" ><i>Eliminar fotos</i></a>&nbsp&nbsp&nbsp
                    	<a href="#" id="linkAddFoto" onclick="abreVentana('f')" ><i>Anexar fotos</i></a>
                    </div></td>
                  </tr>
                   <tr><td colspan=4 ></td></tr>
                </table>
                
                <table width="480" border="0" align="left">
                  <?php echo $trFotos.$trPendientesFotos ?>
                </table>
               
                </fieldset>
                <br />
                <fieldset>
                <legend><strong>DIBUJOS/PLANOS</strong></legend>
                <table width="480" border="0" align="left">
                  <tr>
                    <td colspan=4 ><div align="right">
                    		<a href="#" id="linkAddFoto" onclick="eliminarFile('p')" ><i>Eliminar Dibujo/P</i></a>&nbsp&nbsp&nbsp
                    		<a href="#" id="linkAddDibujo" onclick="abreVentana('p')" ><i>Anexar dibujo/plano</i></a> </div>
                     </td>
                  </tr>
                  <tr><td colspan=4 ></td></tr>
                </table>
                <table width="480" border="0" align="left">
                  <?php echo $trPlanos.$trPendientesPlanos ?>
                </table>
                </fieldset>
                <br />
                <fieldset>
                <legend><strong>VIDEOS</strong></legend>
                <table width="480" border="0" align="left">
                  <tr>
                    <td colspan=4 ><div align="right">
                    	<a href="#" id="linkAddFoto" onclick="eliminarFile('v')" ><i>Eliminar Video</i></a>&nbsp&nbsp&nbsp
                    	<a href="#" id="linkAddVideo" onclick="abreVentana('v')" ><i>Anexar video</i></a> </div></td>
                  </tr>
                  <tr><td colspan=4 ></td></tr>
                </table>
                <table width="480" border="0" align="left">
                   <?php echo $trVideos.$trPendientesVideos ?>
                </table>             
                </fieldset>
                <br />
                <fieldset>
                <legend><strong>INFORMES</strong></legend>
                <table width="480" border="0" align="left">
                  <tr>
                    <td colspan=4 ><div align="right">
                    	<a href="#" id="linkAddInfo" onclick="eliminarFile('i')" ><i>Eliminar Informe</i></a>&nbsp&nbsp&nbsp
                    	<a href="#" id="linkAddVInfo" onclick="abreVentana('i')" ><i>Anexar Informe</i></a> </div></td>
                  </tr>
                  <tr><td colspan=4 ></td></tr>
                </table>
                <table width="480" border="0" align="left">
                   <?php echo $trInformes.$trPendientesInformes ?>
                </table>             
                </fieldset>
             
</div>
  <script>
 function abreVentana(tipo){
    var url = "../upload/menubien.php?tip="+tipo ;
    var miPopup = window.open(url,"miwin","width=800,height=300,scrollbars=yes,menubar=no");
    miPopup.focus();
}
 
 </script>  
 
 <script type="text/javascript">
<!--
	function actualizarMM(){
		$('#tpl_mm').load( 
				"../_templates/cargarMM.php?codUe="+$('#codUE').val()
		)		
	}

	function eliminarFile(el){
		var val ="";
		var nn = "";
		var coma = "";
		$('#checkboxes input:checked').each(function() {     
			nn = '#'+$(this).attr('name');
			val+=coma+$(nn).val();
			coma = ",";
		});

		if(val != ""){
			$('#tpl_mm').load( 
					"../_templates/eliminarCargarMM.php?codUe="+$('#codUE').val()+"&codes="+val
			)			
		}
		
	}
			
//-->
</script>
 
 
 
              